package com.tjp.eight.views;

import android.app.Dialog;
import android.graphics.Point;
import android.support.v4.app.FragmentActivity;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.tjp.eight.R;
import com.tjp.eight.comment.AppManager;

/**
 * Created by Administrator on 2017/3/7.
 */

public class DialogLogin extends Dialog {
    FragmentActivity fragmentActivity;
    private TextView tv_tips;
    private TextView tv_tips_titls;

    public DialogLogin(FragmentActivity fragmentActivity) {
        super(fragmentActivity, R.style.Dialog);

        View view = LayoutInflater.from(fragmentActivity).inflate(R.layout.dialog_login, null);
        tv_tips_titls = (TextView) view.findViewById(R.id.tv_tips_title);
        tv_tips = (TextView) view.findViewById(R.id.tv_tips);

        setContentView(view);

        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        Display display = getWindow().getWindowManager().getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);
        layoutParams.width = point.x;
        layoutParams.gravity = Gravity.CENTER;
        layoutParams.alpha = 1.0f;
        getWindow().setAttributes(layoutParams);

        setCanceledOnTouchOutside(false);
    }

    @Override
    public void onBackPressed() {
        AppManager.getAppManager().finishActivity(fragmentActivity);
        super.onBackPressed();
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

    public void setTv_tips(String msg) {
        tv_tips.setText(msg);
    }

    public void setTv_tips_titls(String tips) {
        tv_tips_titls.setText(tips);
    }
}
